package com.max.common.task;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


/**
 * 
 * 项目名称:max-project-graphics
 * 文件名称:TaskInit.java
 * 文件描述:
 * 创建人员:chenyibo
 * 创建时间:2013-1-29 下午03:07:52
 * 修改人员:chenyibo
 * 修改时间:2013-1-29 下午03:07:52
 * 修改备注:
 * @version V1.0
 */
public class TaskInit 
{
    
	private static Log log = LogFactory.getLog("task");
	
    /**定时任务配置文件名*/
    private static final String TASK_FILE_NAME = "tasks.xml";
    
    /**任务管理器*/
    private static TaskInit instance = null;
    
    
    private TaskInit()
    {
    	
    }
    
    public static synchronized TaskInit getInstance() 
    {
    	if(instance == null)
    	{
    		String configPath = TaskInit.class.getClassLoader().getResource(TASK_FILE_NAME).getFile();
        	log.info("Load config file:" + configPath);
        	
            if(AsyTaskManager.getInstance().init(configPath))
    			log.info("Start all schedualed tasks complete!");
    		else
    			log.info("Start all schedualed tasks failed!");
    	}
    		
    	return instance;
    }
    
    
    public static void main(String[] args)
    {
        TaskInit.getInstance();
    }
}
